/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package simplemetrosystem.view.canvas.MouseHandlers;

import java.awt.Cursor;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.geom.Point2D;
import simplemetrosystem.control.MouseCommandManager;
import simplemetrosystem.view.MetroFrame;
import simplemetrosystem.view.canvas.CanvasModel;

/**
 *
 * @author Eric Qian
 */
public class BasicMouseHandler implements MouseListener, MouseMotionListener {

    /**
     * 
     * @param frame
     */
    public BasicMouseHandler(MetroFrame frame) {
        this.frame = frame;
    }

    public void mouseClicked(MouseEvent e) {
    }

    public void mousePressed(MouseEvent e) {
    }

    public void mouseReleased(MouseEvent e) {
    }

    public void mouseEntered(MouseEvent e) {
    }

    /**
     * 
     * @param e
     */
    public void mouseExited(MouseEvent e) {
        Point2D p = new Point2D.Double(0, 0);
        MouseCommandManager.getInstance().PointDisploy(p);
    }

    public void mouseDragged(MouseEvent e) {
        Point2D p = new Point2D.Double(MouseTrans.X(e.getX()), MouseTrans.Y(e.getY()));
        MouseCommandManager.getInstance().PointDisploy(p);
    }

    /**
     * 
     * @param e
     */
    public void mouseMoved(MouseEvent e) {
        Point2D p = new Point2D.Double(MouseTrans.X(e.getX()), MouseTrans.Y(e.getY()));
        MouseCommandManager.getInstance().PointDisploy(p);
        CanvasModel model = CanvasModel.getInstance();

        int x = MouseTrans.X(e.getX());
        int y = MouseTrans.Y(e.getY());
        model.setHighLight(x, y, 0, 0);
        if (model.isEmpty(x, y)) {
            frame.setCursor(defaultCursor);
        } else {
            frame.setCursor(handCursor);
        }
    }
    private MetroFrame frame;
    protected static Cursor defaultCursor = new Cursor(Cursor.DEFAULT_CURSOR);
    protected static Cursor handCursor = new Cursor(Cursor.HAND_CURSOR);
}
